import requests

s = requests.session()
headers = {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
data = 'username=admin&password=admin123&verifycode=0000'
r = s.post('http://localhost:8081/WoniuSales/user/login', data=data, headers=headers)
content = r.text
if content == 'login-pass':
    print('登陆成功.')
else:
    print('登陆失败.')

# 上传文件
# 定义二进制的文件
upload_file = {'batchfile': (open('销售出库单-20181118-Test.xls', 'rb'))}
data = {'batchname': 'GB20181118'}
r = s.post('http://localhost:8081/WoniuSales/goods/upload', data=data, files=upload_file)
print(r.headers)
